using Voodoo.Sauce.Common.Utils;

namespace Voodoo.Sauce.Internal.CrossPromo.Mercury
{
	public class MercuryTestModeManager
	{
		private enum TestModeState
		{
			Unknown = 0,
			Enabled = 1,
			Disabled = 2
		}

		private const string MERCURY_TEST_MODE_PREFS_KEY = "MercuryApiTestModeKey";

		private static MercuryTestModeManager _instance;

		private TestModeState _testModeState;

		public static MercuryTestModeManager Instance => _instance ?? (_instance = new MercuryTestModeManager());

		public void Initialize()
		{
			_testModeState = (TestModeState)NintendoPlayerPrefs.GetInt("MercuryApiTestModeKey", 0);
		}

		public bool IsTestModeEnabled()
		{
			if (PlatformUtils.UNITY_EDITOR)
			{
				return true;
			}
			return _testModeState == TestModeState.Enabled;
		}

		public void SetTestMode(bool enabled)
		{
			_testModeState = (enabled ? TestModeState.Enabled : TestModeState.Disabled);
			NintendoPlayerPrefs.SetInt("MercuryApiTestModeKey", (int)_testModeState);
		}
	}
}
